<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script language="JavaScript">
        //var reg = /^a/gim ;        // ^ 表示匹配开始  $表示匹配结尾
        var reg = /b$/gim ;
        var str = "ahelloworldb";
        str = str.replace(reg,"A");
        document.write(str);
    </script>
</head>
<body>

</body>
</html>